import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { ConfigService } from '@nestjs/config';

export const getDatabaseConfig = async (
  config: ConfigService,
): Promise<TypeOrmModuleOptions> => ({
  type: 'mysql',
  host: config.get<string>('DB_HOST'),
  port: config.get<number>('DB_PORT'),
  username: config.get<string>('DB_USERNAME'),
  password: config.get<string>('DB_PASSWORD'),
  database: config.get<string>('DB_DATABASE'),
  entities: [__dirname + '/../**/*.entity{.ts,.js}'],
  synchronize: config.get<boolean>('DB_SYNC', false),
  logging: config.get<string>('NODE_ENV') === 'development',
  timezone: '+08:00',
  extra: {
    connectionLimit: 10,
  },
}); 